
# ==============================================================================
# file name: SI-variables.R
# authors: Bernhard Clemm 
# date: March 18, 2022
# purpose: Describe variables
# ==============================================================================

# SETUP ========================================================================

basedir <- paste0(dirname(dirname(
  rstudioapi::getSourceEditorContext()$path)), "/")
codedir <- paste0(basedir, "code/")
datadir <- paste0(basedir, "data/")

library(tidyverse)

survey_pl <- read.csv(paste0(datadir, "processed/survey_pl.csv"))
survey_us <- read.csv(paste0(datadir, "processed/survey_us.csv"))

# Mean / SD / alphas ============================================================

## Partisanship ####

mean(survey_us$party_w3, na.rm = T)
sd(survey_us$party_w3, na.rm = T)

mean(survey_pl$gov_suppopp_w2)
sd(survey_pl$gov_suppopp_w2)

## Self-reported news exposure ####

survey_us %>% 
  select(intersect(starts_with("days_week"), ends_with("w3"))) %>% 
  rowMeans(., na.rm = T) %>% mean(., na.rm = T)
survey_us %>% 
  select(intersect(starts_with("days_week"), ends_with("w3"))) %>% 
  rowMeans(., na.rm = T) %>% sd(., na.rm = T)

survey_pl %>% 
  select(intersect(starts_with("days_week"), ends_with("w2"))) %>% 
  select(-days_week_change_w2) %>%
  rowMeans(., na.rm = T) %>% mean(., na.rm = T)
survey_pl %>% 
  select(intersect(starts_with("days_week"), ends_with("w2"))) %>% 
  select(-days_week_change_w2) %>%
  rowMeans(., na.rm = T) %>% sd(., na.rm = T)

## Self-reported like-minded news exposure  ####

mean(survey_us$newsdiet_ideo_w3, na.rm = T)
sd(survey_us$newsdiet_ideo_w3, na.rm = T)

mean(survey_pl$newsdiet_ideo_w2)
sd(survey_pl$newsdiet_ideo_w2)

## Self-perceived knowledge  ####

mean(survey_us$know_post, na.rm = T)
sd(survey_us$know_post, na.rm = T)
psych::alpha(survey_us %>% select(KNOW_1, KNOW_2, KNOW_3, KNOW_4, KNOW_5))

mean(survey_pl$know_post, na.rm = T)
sd(survey_pl$know_post, na.rm = T)
psych::alpha(survey_pl %>% select(polknow_1_post, polknow_2_post, polknow_3_post, 
                                  polknow_4_post, polknow_5_post))

## Participation  ####

mean(survey_us$ptc_post, na.rm = T)
sd(survey_us$ptc_post, na.rm = T)

mean(survey_pl$ptc_post, na.rm = T)
sd(survey_pl$ptc_post, na.rm = T)

## Attitude importance  ####

mean(survey_us$att_imp_post, na.rm = T)
sd(survey_us$att_imp_post, na.rm = T)
psych::alpha(survey_us %>% select(starts_with("ISPERSO_")))

mean(survey_pl$att_imp_post, na.rm = T)
sd(survey_pl$att_imp_post, na.rm = T)
psych::alpha(survey_pl %>% select(intersect(starts_with("important_"), ends_with("post"))))

## Attitude strength ####

mean(survey_us$att_str_post, na.rm = T)
sd(survey_us$att_str_post, na.rm = T)
psych::alpha(survey_us %>% select(starts_with("ISSTRONG_")))

mean(survey_pl$att_str_post, na.rm = T)
sd(survey_pl$att_str_post, na.rm = T)
psych::alpha(survey_pl %>% select(intersect(starts_with("strong_"), ends_with("post"))))

## Feeling thermometer ####

mean(survey_us$ft_post, na.rm = T)
sd(survey_us$ft_post, na.rm = T)
psych::alpha(survey_us %>% select(
  ft_outparty_post, ft_outideo_post, 
  THERMOM_9, THERMOM_10, THERMOM_11, THERMOM_12, THERMOM_13))

mean(survey_pl$ft_post, na.rm = T)
sd(survey_pl$ft_post, na.rm = T)
psych::alpha(survey_pl %>% select(
  ft_party_opp_post, ft_govopp_post, ft_pissld_post, ft_ideo_opp_post, 
  ft_women_post, ft_relig_post, ft_eu_post, ft_econ_post, ft_pers_post))

## Stupid ####

mean(survey_us$stupid_post, na.rm = T)
sd(survey_us$stupid_post, na.rm = T)
psych::alpha(survey_us %>% select(
  stupid_outparty_post, 
  STUPID_1, STUPID_2, STUPID_3, 
  STUPID_4, STUPID_5, STUPID_6))

mean(survey_pl$stupid_post, na.rm = T)
sd(survey_pl$stupid_post, na.rm = T)
psych::alpha(survey_pl %>% select(
  stupid_party_opp_post, stupid_govopp_post, 
  stupid_women_post, stupid_relig_post, stupid_eu_post, 
  stupid_econ_post, stupid_pers_post))

## Understanding ####

mean(survey_us$under_post, na.rm = T)
sd(survey_us$under_post, na.rm = T)
psych::alpha(survey_us %>% select(
  under_outparty_post, under_outideo_post,
  UNDERSTAND_1, UNDERSTAND_2, UNDERSTAND_3, 
  UNDERSTAND_4, UNDERSTAND_5, UNDERSTAND_6
))

mean(survey_pl$under_post, na.rm = T)
sd(survey_pl$under_post, na.rm = T)
psych::alpha(survey_pl %>% select(
  understand_party_opp_post, under_govopp_post, under_pissld_post, under_ideo_opp_post, 
  understand_women_post, understand_relig_post, understand_eu_post, understand_econ_post, understand_pers_post))

## Attribution of malevolence ####

mean(survey_us$malvol_post, na.rm = T)
sd(survey_us$malvol_post, na.rm = T)
psych::alpha(survey_us %>% select(paste0("MALVOL_", 1:5)))

mean(survey_pl$malvol_post, na.rm = T)
sd(survey_pl$malvol_post, na.rm = T)
psych::alpha(survey_pl %>% select(paste0("malvol_", 1:5, "_post")))

## Support for compromise ####

mean(survey_us$supp_compr_post, na.rm = T)
sd(survey_us$supp_compr_post, na.rm = T)
psych::alpha(survey_us %>% select(paste0("COMPROMISE_", 1:4)))

mean(survey_pl$supp_compr_post, na.rm = T)
sd(survey_pl$supp_compr_post, na.rm = T)
psych::alpha(survey_pl %>% select(paste0("supp_compr_", 1:4, "_post")))

## Perceived pol ####

mean(survey_us$perpol_post, na.rm = T)
sd(survey_us$perpol_post, na.rm = T)
psych::alpha(survey_us %>% select(paste0("PERPOL_", 1:4)))

mean(survey_pl$perpol_post, na.rm = T)
sd(survey_pl$perpol_post, na.rm = T)
psych::alpha(survey_pl %>% select(paste0("perpol_", 1:4, "_post")))

## Mental well-being ####

mean(survey_us$well_feel_post, na.rm = T)
sd(survey_us$well_feel_post, na.rm = T)
psych::alpha(survey_us %>% select(paste0("WELL_FEELINGS_", 1:6)))

mean(survey_pl$well_feel_post, na.rm = T)
sd(survey_pl$well_feel_post, na.rm = T)
psych::alpha(survey_pl %>% select(paste0("well_feel_", 1:6, "_post")))

## Physical well-being ####

mean(survey_us$well_act_post, na.rm = T)
sd(survey_us$well_act_post, na.rm = T)
psych::alpha(survey_us %>% select(paste0("WELL_ACT_", 1:5)))

mean(survey_pl$well_feel_post, na.rm = T)
sd(survey_pl$well_feel_post, na.rm = T)
psych::alpha(survey_pl %>% select(paste0("well_act_", 1:5, "_post")))
